import { request } from 'umi';

import type { HttpResponseWrap } from '@/types/Common';

/**
 * @param params 获取通知信息
 */
export async function getMsgDatas(params: SearchParams) {
  return request<HttpResponseWrap<msgParams[]>>('/api/SaasMessage/QueryUserMessages', {
    method: 'POST',
    data: params,
  });
}

/**
 * @param params 设置消息已读
 */
export async function setMsgStatus(params: string[]) {
  return request<HttpResponseWrap<msgParams[]>>('/api/SaasMessage/SetMessageRead', {
    method: 'POST',
    data: params,
  });
}

export interface msgParams {
  id: string;
  category: number;
  titile: string;
  content: string;
  receiveUserId: string;
  isRead: boolean;
  readDate: string;
  isDeleted: boolean;
  createTime: string;
  createUserId: string;
  createUserName: string;
  createUserCardNo: string;
  modifyTime: string;
  modifyUserId: string;
  modifyUserName: string;
  modifyUserCardNo: string;
}

export interface SearchParams {
  category?: number;
  isRead?: boolean;
  keywords?: string;
  timeFrom?: string;
  timeTo?: string;
}
